#include "Cmn.h"
#include <ctime>
void Time(int &day, int &month, int &year)
{
	time_t t=time(0);   // get time now
	struct tm *now=localtime(&t);
	year=now->tm_year+1900;
	month=now->tm_mon+1;
	day=now->tm_mday;
}
void	monthAttributesPortable(__int32 year, __int32 month, __int32 *firstSunday, __int32 *nDays)
{
	switch(month)
	{
	case 1:											*nDays=31;break;
	case 2:		 if(400*__int32(year/400)==year)	*nDays=29;
			else if(100*__int32(year/100)==year)	*nDays=28;
			else if(  4*__int32(year/  4)==year)	*nDays=29;
			else									*nDays=28;break;
	case 3:											*nDays=31;break;
	case 4:											*nDays=30;break;
	case 5:											*nDays=31;break;
	case 6:											*nDays=30;break;
	case 7:											*nDays=31;break;
	case 8:											*nDays=31;break;
	case 9:											*nDays=30;break;
	case 10:										*nDays=31;break;
	case 11:										*nDays=30;break;
	case 12:										*nDays=31;break;
	}
	__int64 absoluteDay=365*(year-1)+__int32((year-1)/4)-__int32((year-1)/100)+__int32((year-1)/400);
	switch(month)
	{
	case 2:	absoluteDay+= 31;break;
	case 3:	absoluteDay+= 59;break;
	case 4:	absoluteDay+= 90;break;
	case 5:	absoluteDay+=120;break;
	case 6:	absoluteDay+=151;break;
	case 7:	absoluteDay+=181;break;
	case 8:	absoluteDay+=212;break;
	case 9:	absoluteDay+=243;break;
	case 10:absoluteDay+=273;break;
	case 11:absoluteDay+=304;break;
	case 12:absoluteDay+=334;break;
	}
	if(month>2)
	{
			 if(400*__int32(year/400)==year)	absoluteDay++;
		else if(100*__int32(year/100)==year)	;
		else if(  4*__int32(year/  4)==year)	absoluteDay++;
		else									;
	}
	*firstSunday=7-(absoluteDay+6+1)%7;
}